
import useLogout from "@/hooks/useLogout";
import AppTheme from "@/theme";
import { NavigationProp, useNavigation } from "@react-navigation/native";
import { DevSettings, Pressable, Text, View } from "react-native";
import { PanGestureHandlerGestureEvent, PanGestureHandler } from "react-native-gesture-handler";
// import Animated, { useSharedValue, useAnimatedStyle, useAnimatedGestureHandler } from "react-native-reanimated";

export default function ViewLog() {
  const navigation = useNavigation<NavigationProp<AuthStackParamList & CommonStackParamList, 'NetworkLoggerView'>>();


  // const x = useSharedValue(0);
  // const y = useSharedValue(0);
  // const uas = useAnimatedStyle(() => {
  //   return {
  //     transform: [{ translateX: x.value }, { translateY: y.value }],
  //   };
  // });

  type contextType = {
    translationY: number;
    translationX: number;
  };

  // const gestureHandler = useAnimatedGestureHandler<
  //   PanGestureHandlerGestureEvent,
  //   contextType
  // >({
  //   onStart: (event, context) => {
  //     context.translationX = x.value;
  //     context.translationY = y.value;
  //   },
  //   onActive: (event, context) => {
  //     x.value = event.translationX + context.translationX;
  //     y.value = event.translationY + context.translationY;
  //   },
  //   onEnd: (event, context) => {
  //     // x.value = withSpring(0)
  //     // y.value = withSpring(0)
  //   },
  // });

  const onReload = () => {
    DevSettings.reload();
  };

  const goLog = () => {
    navigation.navigate("NetworkLoggerView");
  };

  const Logout = useLogout()

  return (
    <>
      <View
        style={[{
          position: "absolute",
          bottom: 160,
          right: 40,
        },
        ]}
      >
        <Pressable
          style={{
            marginVertical: 5,
            backgroundColor: AppTheme.colors.green,
            padding: 5,
          }}
          onPress={onReload}
        >
          <Text>卡死{"\n"}重载</Text>
        </Pressable>

        <Pressable
          style={{
            marginVertical: 5,
            backgroundColor: AppTheme.colors.green,
            padding: 5,
          }}
          onPress={goLog}
        >
          <Text>网络{"\n"}日志</Text>
        </Pressable>


        <Pressable
          style={{
            marginVertical: 5,
            backgroundColor: AppTheme.colors.green,
            padding: 5,
          }}
          onPress={() => Logout()}
        >
          <Text>重置</Text>
        </Pressable>

      </View>
    </>
  );
};
